package com.niuke;

import java.util.HashSet;

/**
 * Description:
 * Copyright:   Copyright (c)2019
 * Company:     zefu
 *
 * @author: 张李鑫
 * @version: 1.0
 * Create at:   2021-12-10 14:11:41
 * <p>
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2021-12-10     张李鑫                     1.0         1.0 Version
 */
public class JZ3 {


    public int duplicate(int[] numbers) {
        // write code here
        HashSet<Integer> set = new HashSet<>();

        for (int number : numbers) {
            if (!set.add(number)) {
                return number;
            }
        }
        return -1;
    }


    public static void main(String[] args) {
        HashSet<Integer> set = new HashSet<>();
        System.out.println(set.add(1));
        System.out.println(set.add(1));
    }
}
